package cn.enilu.guns.bean.entity.door;


import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import cn.enilu.guns.bean.entity.BaseEntity;
import org.hibernate.annotations.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity(name="T_DOOR_INFO")
@Table(appliesTo = "t_door_info",comment = "门信息")
@Getter
@Setter
@ToString(exclude="entranceGuardRules")
//@EqualsAndHashCode(exclude="entranceGuardRules")
@EntityListeners(AuditingEntityListener.class)

public class DoorInfo extends BaseEntity {

//	@ManyToMany(mappedBy = "doorInfos",fetch = FetchType.LAZY)
//	@JsonBackReference
//	private Set<EntranceGuardRule> entranceGuardRules = new HashSet<>();

	/**
	 * 
	 */
	@Column(columnDefinition = " INT(10) COMMENT ''")
	private Integer version;

	/**
	 * 门名称
	 */
	@Column(columnDefinition = " VARCHAR(64) COMMENT '门名称'")
	private String doorName;

	/**
	 * 区域id
	 */
	@Column(columnDefinition = " BIGINT(19) COMMENT '区域id'")
	private Long areaId;

	/**
	 * 门所属设备
	 */
//	@Column(columnDefinition = " BIGINT(19) COMMENT '门所属设备'")
//	private Long equipmentId;

	@JoinColumn(name="equipment_id", referencedColumnName = "id",  columnDefinition = "BIGINT(19) COMMENT '门所属设备'", updatable = false)
	@ManyToOne(fetch = FetchType.EAGER)
	private EquipmentInfo equipmentInfo;
	/**
	 * 门磁类型
	 */
	@Column(columnDefinition = " VARCHAR(32) COMMENT '门磁类型'")
	private String doorType;

	/**
	 * 验证方式
	 */
	@Column(columnDefinition = " VARCHAR(32) COMMENT '验证方式'")
	private String verificationMode;

    /**
     * 设备编号
     */
    @Column(columnDefinition = " VARCHAR(32) COMMENT '设备编号'")
    private String doorNo;

}
